package com.ourteam.product.api;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ourteam.frame.controller.AbstractCRUDServiceController;
import com.ourteam.product.ui.dao.ProductUITabItemDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUITabItemBean;
import com.ourteam.product.ui.service.IProductUIService;
import com.ourteam.product.ui.service.ProductUIServiceFactory;

@Controller
@RequestMapping("/api/PRODUCT/UI/productUITabItem")
public class ProductUITabItemAPI extends
		AbstractCRUDServiceController<ProductUITabItemDAOQueryBean, ProductUITabItemSearchModel, ProductUITabItemBean> {

	private static final IProductUIService PRODUCT_UI_SERVICE = ProductUIServiceFactory.getProductUIService();

	@Override
	protected ProductUITabItemDAOQueryBean newQueryBean() {
		return new ProductUITabItemDAOQueryBean();
	}

	@Override
	protected int queryCount(ProductUITabItemDAOQueryBean queryBean) throws Exception {
		return PRODUCT_UI_SERVICE.queryProductUITabItemCount(queryBean);
	}

	@Override
	protected ProductUITabItemBean[] queryData(ProductUITabItemDAOQueryBean queryBean) throws Exception {
		return PRODUCT_UI_SERVICE.queryProductUITabItems(queryBean);
	}

	@Override
	protected void deleteData(long[] ids) throws Exception {
		PRODUCT_UI_SERVICE.deleteProductUITabItems(ids);
	}

	@Override
	protected ProductUITabItemBean getDataById(long id) throws Exception {
		return PRODUCT_UI_SERVICE.getProductUITabItemById(id);
	}

	@Override
	protected void saveData(ProductUITabItemBean dataBean) throws Exception {
		//dataBean.setLastModifyTime(new Date());
		//dataBean.setLastModifyUser(getLoginUserName());
		if (dataBean.getId() == 0) {
			PRODUCT_UI_SERVICE.addNewProductUITabItem(dataBean);
		} else {
			PRODUCT_UI_SERVICE.modifyProductUITabItem(dataBean);
		}
	}

}
